# -*- python -*-
# ex: set syntax=python:
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# See master.experimental/slaves.cfg for documentation.

def linux():
  chromeos_boards = ('x86-generic', 'amd64-generic', 'daisy')
  cq_slaves = (range(111, 131) + range(162, 399) + range(427, 453) +
               range(493, 497) + range(506, 540) + range(590, 600) +
               range(621, 651) + range(779, 799) + range(800, 837) +
               range(841, 864) + range(878, 897) + range(909, 915) +
               range(1010, 1029) + range(1276, 1286))
  cq_builders = [
    'cast_shell_linux',
    'cast_shell_audio_linux',
    'chromium_devtools',
    'chromium_presubmit',
    'linux_chromium_archive_rel_ng',
    'linux_chromium_asan_rel_ng',
    'linux_chromium_chromeos_asan_rel_ng',
    'linux_chromium_chromeos_compile_dbg_ng',
    'linux_chromium_chromeos_ozone_rel_ng',
    'linux_chromium_chromeos_rel_ng',
    'linux_chromium_clobber_rel_ng',
    'linux_chromium_compile_dbg_ng',
    'linux_chromium_rel_ng',
    'linux_chromium_tsan_rel_ng',
  ]
  cq_builders += [
    'chromeos_%s_chromium_compile_only_ng' % (board,)
    for board in chromeos_boards
  ]

  # Slave pools have two competing constraints:
  #  - load: peak number of concurrent builds. Larger pools are safer.
  #  - disk space: too many builders on the same pool will exhaust
  #     the disk space on all slaves. Smaller pools are safer.
  #
  # Currently, we need two optional pools due to disk space. When
  # adding new builders, try sharing the existing slavebuilddir.
  optional_slaves1 = [568, 747, 866, 867] + range(1098, 1102)
  optional_slaves2 = range(714, 719)

  # Contain all the builders with the following large slavebuilddir:
  #  - linux
  #  - linux_chromeos
  #  - linux_msan
  optional_builders1 = [                      # slavebuilddir
    'closure_compilation',                    # linux
    'linux_chromium_chromeos_compile_rel_ng', # linux_chromeos
    'linux_chromium_chromeos_dbg_ng',         # linux_chromeos
    'linux_chromium_chromeos_variable',       # linux_chromeos
    'linux_chromium_compile_dbg_32_ng',       # linux
    'linux_chromium_compile_rel_ng',          # linux
    'linux_chromium_dbg_ng',                  # linux
    'linux_chromium_dbg_32_ng',               # linux
    'linux_chromium_msan_rel_ng',             # linux_msan
    'linux_chromium_ubsan_rel_ng',            # linux ubsan
    'linux_chromiumos_full_variable',         # linux_chromeos
    'linux_chromium_ozone_compile_only_ng',   # linux
    'linux_site_isolation',                   # linux
    'linux_chromium_browser_side_navigation_rel', # linux
    'linux_chromium_analysis',                # linux
    'linux_mojo',                             # linux
    'linux_mojo_chromeos',                    # linux_chromeos
  ]
  # Contains all the optional builders with smaller slavebuilddir not
  # covered by optional_builders1.
  optional_builders2 = [
    'chromeos_%s_variable' % (board,)         # chromeos_<board>
    for board in chromeos_boards
  ]
  optional_builders2 += [
    'linux_arm',                              # linux_arm
    'linux_chromium_chromeos_asan_variable',  # linux_chromeos_asan
    'linux_chromium_chromeos_msan_rel_ng',    # linux_chromeos_msan
    'linux_chromium_chromeos_msan_variable',  # linux_chromeos_msan
    'linux_chromium_chromeos_variable_chrome',# linux_chromeos_chrome
    'linux_chromium_gn_upload',               # build_and_upload_gn
    'linux_nacl_sdk',                         # linux_nacl_sdk
    'linux_nacl_sdk_build',                   # linux_nacl_sdk_build
    'linux_optional_gpu_tests_rel',           # linux_nacl_sdk_build
  ]

  # Super beefy machines.
  optional_highmem_slaves = [904, 905]
  optional_highmem_builders = [
    'linux_upload_clang',
    'linux_chromium_cfi_rel_ng',
  ]

  # High-cpu slaves for dedicated use by Findit.
  optional_highcpu_slaves = [799] + range(873, 878)
  optional_highcpu_builders = [               # slavebuilddir
    'linux_chromium_asan_variable',           # linux_asan
    'linux_chromium_variable',                # linux
    'linux_chromium_component_updater',       # linux
    'linux_chromium_cast_variable',           # linux_cast
    'linux_chromium_msan_variable',           # linux_msan
    'linux_chromium_variable_32',             # linux_32
    'linux_chromium_variable_chrome',         # linux_chrome
    'linux_chromium_variable_clobber',        # linux_clobber
    'linux_chromium_webkit_asan_variable',    # linux_layout_asan
    'linux_chromium_webkit_leak_variable',    # linux_layout_leak
    'linux_chromium_webkit_msan_variable',    # linux_layout_msan
    'linux_chromium_webkit_variable',         # linux_layout
    'linux_chromium_tsan_variable',           # linux_tsan
  ]
  optional_highcpu_slaves_2 = range(1396, 1398)
  optional_highcpu_builders_2 = [
    'linux_chromium_variable_deflake',
    'linux_chromium_chromeos_variable_deflake',
  ]

  # Set up normal slaves.
  result = []
  for i, slave in enumerate(cq_slaves):
    result.append({
      'master': 'TryServerChromiumLinux',
      'os': 'linux',
      'version': 'trusty',
      'bits': '64',
      'builder': cq_builders,
      'preferred_builder': cq_builders[i % len(cq_builders)],
      'hostname': 'slave%d-c4' % slave,
      'pool': 'linux_cq',
    })
  for slave in optional_slaves1:
    result.append({
      'master': 'TryServerChromiumLinux',
      'os': 'linux',
      'version': 'trusty',
      'bits': '64',
      'builder': optional_builders1,
      'hostname': 'slave%d-c4' % slave,
      'pool': 'linux_optional1',
    })
  for slave in optional_slaves2:
    result.append({
      'master': 'TryServerChromiumLinux',
      'os': 'linux',
      'version': 'trusty',
      'bits': '64',
      'builder': optional_builders2,
      'hostname': 'slave%d-c4' % slave,
      'pool': 'linux_optional2',
    })
  for slave in optional_highmem_slaves:
    result.append({
      'master': 'TryServerChromiumLinux',
      'os': 'linux',
      'version': 'trusty',
      'bits': '64',
      'builder': optional_highmem_builders,
      'hostname': 'slave%d-c4' % slave,
      'pool': 'linux_optional_highmem',
    })
  for slave in optional_highcpu_slaves:
    result.append({
      'master': 'TryServerChromiumLinux',
      'os': 'linux',
      'version': 'trusty',
      'bits': '64',
      'builder': optional_highcpu_builders,
      'hostname': 'slave%d-c4' % slave,
      'pool': 'linux_optional_highcpu',
    })
  for slave in optional_highcpu_slaves_2:
    result.append({
      'master': 'TryServerChromiumLinux',
      'os': 'linux',
      'version': 'trusty',
      'bits': '64',
      'builder': optional_highcpu_builders_2,
      'hostname': 'slave%d-c4' % slave,
      'pool': 'linux_optional_highcpu_2',
    })

  for slave in (775, 1404, 1405):
    result.append(
      {
        'master': 'TryServerChromiumLinux',
        'os': 'linux',
        'version': 'trusty',
        'bits': '64',
        'builder': ['linux_layout_tests_slimming_paint_v2'],
        'hostname': 'slave%d-c4' % slave,
        'pool': 'linux_layout_tests_slimming_paint_v2',
      })

  result.append({
    'master': 'TryServerChromiumLinux',
    'os': 'linux',
    'version': 'trusty',
    'bits': '64',
    'builder': ['linux_layout_tests_layout_ng'],
    'hostname': 'slave1403-c4',
    'pool': 'linux_layout_tests_layout_ng',
  })

  # Slaves for linux_chromium_headless_rel.
  headless_slaves = [426, 497, 776, 864, 865, 872] + range(1069, 1098)
  for slave in headless_slaves:
    result.append({
      'master': 'TryServerChromiumLinux',
      'os': 'linux',
      'version': 'trusty',
      'bits': 64,
      'builder': ['linux_chromium_headless_rel'],
      'hostname': 'slave%d-c4' % slave,
      'pool': 'linux_chromium_headless_rel',
    })

  result.append({
      'master': 'TryServerChromiumLinux',
      'os': 'linux',
      'version': 'trusty',
      'bits': '64',
      'builder': ['linux_chromium_clobber_deterministic'],
      'hostname': 'slave1388-c4',
      'pool': 'linux_deterministic',
  })

  return result


slaves = linux()
